package com.jweb.framework.http.support;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.jweb.framework.http.RefererResolver;
/**
 * 修改人： Thomas
 * 修改内容：新增 
 * 类说明：
 */
public class DefaultRefererResolver implements RefererResolver {
	
	public static final String DEFAULT_PARAM_NAME = "referer" ;
	private String paramName = "referer" ;
	
	public void setParamName(String name){
		this.paramName = name ;
	}
	
	public String getParamName(){
		return this.paramName ;
	}

	public String resolveReferer(HttpServletRequest request , Map<String, String[]> map) {
		
		String str = request.getParameter(this.paramName); // str=null
		if(map != null){
			map.remove(this.paramName);
		}
		
		return str ;
	}

	public void setReferer(HttpServletRequest request) {
		
		String str = (String) request.getAttribute(this.paramName) ;
		if(str == null){
			str = Utils.getReferer(request);
			request.setAttribute(this.paramName, str) ;
		}
	}
	
}
